home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Classes / 2.0_GraphView / Examples / Logger / GraphView.h < prev    next >
Encoding:
Text File  |  1992-07-27  |  10.7 KB  |  462 lines

  1. /*
  2. Graph View is placed in the public domain for non-commercial use by not-for-profit educational institutions in the United States.   All other rights reserved.
  3.  
  4. */
  5.  
  6. /*
  7.  
  8. Add the following files if you want to use a GraphView object in your application:
  9.  
  10. CommonDefs.h
  11. GraphView.h
  12. libGraphView.a
  13. GraphViewControls.nib
  14. cross.tiff
  15. Unzoom.tiff
  16.  
  17. */
  18.  
  19.  
  20. #import <appkit/View.h>
  21. #import "CommonDefs.h"
  22.  
  23. typedef struct
  24.         {
  25.             float redVal;
  26.             float greVal;
  27.             float bluVal;
  28.         }colorType;
  29.  
  30. typedef struct
  31.         {
  32.             NXDPoint    coords;
  33.             int        penStyle;
  34.             colorType    penColor;
  35.             double        size;
  36.         }storedDataType;
  37.         
  38. typedef struct
  39.         {
  40.             double        edge;
  41.             double        height;
  42.             double        size;
  43.             colorType    penColor;
  44.         }sortedHistogramDataType;
  45.  
  46. typedef struct
  47.         {
  48.             NXDPoint    data;
  49.             double        binEdge;
  50.             double        size;
  51.             colorType    penColor;
  52.         }rawHistogramDataType;
  53.                 
  54. typedef struct
  55.         {    double    xmin, xmax, ymin, ymax;
  56.         }graphExtremeties;
  57.         
  58. #define CENTRE 0
  59. #define TOP 2
  60. #define BOTTOM 1
  61. #define LEFT 1
  62. #define RIGHT 2
  63. #define ORIGIN 3
  64.  
  65. #define LIFT 0
  66. #define SLINE 1
  67. #define DLINE 2
  68. #define CIRCLE 3
  69. #define SQUARE 4
  70.  
  71. #define MINIMALASCIICOPY 1
  72. #define FULLASCIICOPY 2
  73.  
  74. #define    CORRECTMARGINS 0
  75. #define LABELIFMARGIN 1
  76.  
  77. #define    DPSDATALIMIT 2048
  78. #define    DPSOPLIMIT 1024
  79.  
  80. #define LINEAR 0
  81. #define LOG 1
  82. #define POLAR 2
  83.  
  84. #define    HORIZONTAL 0
  85. #define VERTICAL 1
  86.  
  87. @interface GraphView:View
  88. {    
  89.     id    crossCursor;
  90.     id    unZoomCursor;
  91.     id    dataPoints;
  92.     id     rawHistPoints;
  93.     id    sortedHistPoints;
  94.     id    xMinField;
  95.     id    xMaxField;
  96.     id    yMinField;
  97.     id    yMaxField;
  98.     id    xMajTickWidthField;
  99.     id    yMajTickWidthField;
  100.     id    xTickStartField;
  101.     id    yTickStartField;
  102.     id    cBinEdgeField;
  103.     id    binWidthField;
  104.     id    binOffsetField;
  105.     id    maxStrokeRatioField;
  106.     id    thePasteBoard;
  107.     id    xAutoSW;
  108.     id    yAutoSW;
  109.     id    nibIncreaseButton;
  110.     id    nibDecreaseButton;
  111.     id    strokeIncreaseButton;
  112.     id    strokeDecreaseButton;
  113.     id    pointRadiusField;
  114.     id    lineThicknessField;
  115.     id    strokeWidthField;
  116.     id    readOut;
  117.     id    zoomList;
  118.     id    delegate;
  119.     id    snapShot;
  120.     id    xPlotModeSelector;
  121.     id    yPlotModeSelector;
  122.     id    oldEdgeField;
  123.     id    newEdgeField;
  124.     id    controlPanel;        //Do not archive!!
  125.     id    histogramInspector;    //Do not archive!!
  126.     
  127.     // Some color definitions
  128.     
  129.     colorType gridColor;
  130.     colorType grBackColor;
  131.     colorType ticksColor;
  132.     colorType scaleColor;
  133.     colorType axesColor;
  134.     colorType titleColor;
  135.     colorType xyTitleColor;
  136.     colorType axesOrderColor;
  137.     colorType marginColor;
  138.     colorType outlineColor;
  139.  
  140.     // Pen Attributes
  141.     
  142.     colorType    cPenColor;
  143.     int        cPenStyle;
  144.     
  145.     // Miscelleneous
  146.     BOOL    graphViewInitialized;    
  147.     BOOL    xAutoscale;
  148.     BOOL    yAutoscale;
  149.     BOOL    canScroll;
  150.     BOOL    gridVisible;
  151.     BOOL    majTicksVisible;
  152.     BOOL    minTicksVisible;
  153.     BOOL    xAxisVisible;
  154.     BOOL    yAxisVisible;
  155.     BOOL    labelsVisible;
  156.     BOOL    drawingEnabled;
  157.     BOOL    psOpsAllowed;
  158.     BOOL    userWarnedForPSOps;
  159.     BOOL    drawInColor;
  160.     BOOL    snapShotIsCurrent;
  161.     BOOL    snapShotOK;
  162.     BOOL    controlPanelOpen;
  163.     BOOL    axisSynchronized;
  164.     int    histogramOrientation;
  165.     int    xAxisLoc;
  166.     int    yAxisLoc;
  167.     int    numMinorTicks;
  168.     int    maxTickLimit;
  169.     int    normTickLimit;
  170.     int    asciiCopyType;
  171.     int    labelDisplayOption;
  172.     int     xPlotMode;
  173.     int    yPlotMode;
  174.     double    cBinEdge;        // Required for histograms
  175.     double    binWidth;        // Required for histograms
  176.     double    binOffset;        // Required for histograms
  177.     double    currentNibInc;
  178.     double    autoscaleInc;
  179.     double    xOrder;             //Order of extremeties
  180.     double    yOrder;
  181.     double    xAxPos, yAxPos, xOLabelPos, yOLabelPos;
  182.     double    xTickStart, yTickStart;
  183.     double    xMajTickWidth;
  184.     double    yMajTickWidth;
  185.     double    lineThickness;
  186.     double    histStrokeWidth;
  187.     double    maxStrokeRatio;        //Fraction of bin width
  188.     double    pointRadius;
  189.     double    xMin;
  190.     double    xMax;
  191.     double    yMin;
  192.     double    yMax;
  193.     double    yMargins;
  194.     double    xMargins;
  195.     double    defLineWidth;
  196.     double    gutterWidth;
  197.     double    xMarginWidth;
  198.     double    yMarginWidth;
  199.     double    titleXPos, titleYPos;
  200.     char    *graphTitlePtr;
  201.     char    *xTitlePtr;
  202.     char    *yTitlePtr;
  203.     
  204.     
  205.     // Line Dashing Patterns
  206.     
  207.     float    pat1[0];
  208.     float    pat2[1];
  209.     float    bbox[4];
  210. }
  211.  
  212. //    The following procedures initialize the object and control its general behavior;
  213.  
  214. - initFrame:(const NXRect *)frameRect;
  215. - read:(NXTypedStream*)stream;
  216. - write:(NXTypedStream*)stream;
  217. - readCoordData:(NXTypedStream *)stream;
  218. - readHistData:(NXTypedStream *)stream;
  219. - writeCoordData:(NXTypedStream *)stream;
  220. - writeHistData:(NXTypedStream *)stream;
  221. - awake;
  222.  
  223. //    These are methods that involve the actual data.
  224.  
  225. - acceptContentsFrom:(NXDPoint *)anArrayPtr arrayOfLength:(int) aLength asNewTrace: (BOOL) newTrace;
  226. - drawWithContentsFrom:(NXDPoint *)anArrayPtr arrayOfLength:(int) aLength asNewTrace:(BOOL) newTrace;
  227. - clearDataInfo:sender;
  228. - determineXExtremeties;
  229. - determineYExtremeties;
  230. - rescaleX:sender;
  231. - rescaleY:sender;
  232.  
  233. //    The following methods deal with the scaling of the graphView window.
  234.  
  235. - setXAutoscale:(BOOL) decision;
  236. - setYAutoscale:(BOOL) decision;
  237. - (BOOL) xAutoscale;
  238. - (BOOL) yAutoscale;
  239. - toggleXAutoscale:sender;
  240. - toggleYAutoscale:sender;
  241. - setAutoscaleIncrementTo:(double) incr;
  242. - (double) autoscaleIncrement;
  243.  
  244. // GraphView Ranges
  245.  
  246. - manualXMin:(double) val;
  247. - manualXMax:(double) val;
  248. - manualYMin:(double) val;
  249. - manualYMax:(double) val;
  250. - (double) xMin;
  251. - (double) xMax;
  252. - (double) yMin;
  253. - (double) yMax;
  254.     
  255. - setScrollMode:(BOOL) decision;
  256. - receiveXMinFrom:sender;
  257. - receiveXMaxFrom:sender;
  258. - receiveYMinFrom:sender;
  259. - receiveYMaxFrom:sender;
  260. - setDefaultX;
  261. - setDefaultY;
  262. - postExtremeties;
  263.  
  264. //    The next few methods deal with the format of the plot window.
  265.  
  266. - syncAxesToTicks:sender;
  267. - setAxesToOrigin:sender;
  268. - setXAxisLocationTo:(int) loc;
  269. - setYAxisLocationTo:(int) loc;
  270. - setXMajorTickWidthTo:(double) num;
  271. - setYMajorTickWidthTo:(double) num;
  272. - receiveXMajorTickWidthFrom:sender;
  273. - receiveYMajorTickWidthFrom:sender;
  274. - setXTickStartTo:(double) num;
  275. - setYTickStartTo:(double) num;
  276. - receiveXTickStartFrom:sender;
  277. - receiveYTickStartFrom:sender;
  278. - setNumMinorTicksTo:(int) num;
  279. - receiveNumMinorTicksFrom:sender;
  280. - setMaxNumMajTicksTo:(int) num;
  281. - setNormNumMajTicksTo:(int) num;
  282. - (int) xAxisLocation;
  283. - (int) yAxisLocation;
  284. - (double) xMajorTickWidth;
  285. - (double) yMajorTickWidth;
  286. - (int) numMinorTicks;
  287. - (int) maxNumMajTicks;
  288. - (int) normNumMajTicks;
  289.  
  290. //  Labels and ticks show status
  291.  
  292. - showMajorTicks:(BOOL) decision;
  293. - showMinorTicks:(BOOL) decision;
  294. - showGrid:(BOOL) decision;
  295. - showXAxis:(BOOL) decision;
  296. - showYAxis:(BOOL) decision;
  297. - showLabels:(BOOL) decision;
  298. - toggleMajorTicks:sender;
  299. - toggleMinorTicks:sender;
  300. - toggleGrid:sender;
  301. - toggleXAxis:sender;
  302. - toggleYAxis:sender;
  303. - toggleLabels:sender;
  304. - showAllTicksAndLabels:(BOOL) decision;
  305. - (BOOL) gridVisible;
  306. - (BOOL) majorTicksVisible;
  307. - (BOOL) minorTicksVisible;
  308. - (BOOL) xAxisVisible;
  309. - (BOOL) yAxisVisible;
  310. - (BOOL) labelsVisible;
  311.  
  312. // gutters and margins
  313. - setGutterWidthTo:(double)val;
  314. - setXMarginWidthTo:(double)val;
  315. - setYMarginWidthTo:(double)val;
  316. - (double) gutterWidth;
  317. - (double) xMarginWidth;
  318. - (double) yMarginWidth;
  319.  
  320. // Rendering Options
  321. - setPSOpsAllowed:(BOOL)decision;
  322. - setWarningForPSOps:(BOOL)decision;
  323. - setDrawInColorTo:(BOOL)decision;
  324. - setDrawingEnabledTo:(BOOL)decision;
  325. - (BOOL) psOpsAllowed;
  326. - (BOOL) userWarnedForPSOps;
  327. - (BOOL) drawInColor;
  328. - (BOOL) drawingEnabled;
  329.     
  330.         
  331. //    The following methods concern the plot style and text.
  332.  
  333. - setTitleTo:(char *) theTitlePtr at:(double)xPercent:(double)yPercent;
  334. - setXTitleTo:(char *) theXTitlePtr;
  335. - setYTitleTo:(char *) theYTitlePtr;
  336. - setLabelDisplayOptionTo:(int) val;
  337. - (int) labelDisplayOption;
  338. - (char *) title;
  339. - (double) titleXPos;
  340. - (double) titleYPos;
  341. - (char *) xTitle;
  342. - (char *) yTitle;
  343.  
  344. // Modifying pen attributes
  345.  
  346. - setPointRadiusTo:(double) aSize;         // As a fraction of the window width in pixels
  347. - setLineThicknessTo:(double) aThickness;    // As a fraction of the window width in pixels
  348. - setNibSizeIncTo:(double) nibInc;
  349. - (double) pointRadius;
  350. - (double) lineThickness;
  351. - (double) currentNibInc;
  352. - changeGlobalPenSize:sender;
  353. - setCurrentPenStyleTo:(int) aStyle;
  354. - (int) currentPenStyle;
  355.  
  356. // Modifying the histogram
  357. - setHistogramStrokeWidthTo:(double) aWidth;    // As a fraction of the window width in pixels
  358. - changeGlobalHistogramStrokeWidth:sender;
  359. - setMaxStrokeRatioTo:(double) fractionWidth;        // As a fraction of bin width;
  360. - receiveMaxStrokeRatioFrom:sender;
  361. - (double) histogramStrokeWidth;
  362. - (double) maxStrokeRatio;
  363. - relocateEdge:(double)oldEdge to:(double) newEdge;
  364. - relocateEdge:sender;
  365. - setCurrentBinEdgeTo:(double) edge;
  366. - receiveCurrentBinEdgeFrom:sender;
  367. - (double) currentBinEdge;
  368. - setBinWidthTo:(double) width;
  369. - receiveBinWidthFrom:sender;
  370. - (double) binWidth;
  371. - setBinOffsetTo:(double) width;
  372. - receiveBinOffsetFrom:sender;
  373. - (double) binOffset;
  374.  
  375.  
  376. // Histogram Orientation
  377.  
  378. - setHistogramOrientationTo:(int)orientation;
  379. - selectHistogramOrientation:sender;        // To be used with a radio button pair only
  380.  
  381. // Plotting Modes & associated methods
  382. - setXPlotModeTo:(int) mode;
  383. - selectXPlotModeFrom:sender;
  384. - (int) xPlotMode;
  385. - setYPlotModeTo:(int) mode;
  386. - selectYPlotModeFrom:sender;
  387. - (int) yPlotMode;
  388.  
  389. //    The following method is used for defining the colors;
  390.  
  391. - (colorType *) gridColor;
  392. - (colorType *) grBackColor;
  393. - (colorType *) ticksColor;
  394. - (colorType *) scaleColor;
  395. - (colorType *) axesColor;
  396. - (colorType *) titleColor;
  397. - (colorType *) xyTitleColor;
  398. - (colorType *) axesOrderColor;
  399. - (colorType *) marginColor;
  400. - (colorType *) outlineColor;
  401. - (colorType *) currentPenColor;
  402.     
  403. - setTheColorOf:(colorType *)theColor toRGBColor:(float) rVal:(float) gVal:(float) bVal;
  404. - setCurrentPenColorToRGBColor:(float) rVal:(float) gVal:(float) bVal;
  405. - setTheColorOf:(colorType *)theColor toHSBColor:(float) hVal:(float) sVal:(float) bVal;
  406. - setCurrentPenColorToHSBColor:(float) hVal:(float) sVal:(float) bVal;
  407.  
  408. //    Copying Data
  409.  
  410. - setAsciiCopyTypeTo:(int)type;
  411. - (int) asciiCopyType;
  412. - copyAsciiDataToPboard:sender;
  413. - copyPSDataToPboard:sender;
  414. - copyArchiveDataToPboard:sender;
  415. - pasteArchiveDataFromPboard:sender;
  416.  
  417. //    And finally the plotting mathods.
  418.  
  419. - (BOOL) lockFocusAndClip;
  420. - redrawGraph;
  421. - drawSelf:(const NXRect *)rects :(int)rectCount;
  422. - mouseDown:(NXEvent *)theEvent;
  423. - clearMargins;
  424. - drawAxes:(const NXRect *)rects :(int)rectCount;
  425. - plotTheData:(const NXRect *)rects :(int)rectCount;
  426. - addThePoint:(NXDPoint) aPoint;
  427. - addHistogramPoint:(NXDPoint) anyPoint;
  428. - drawLineFrom:(NXDPoint) firstPoint to:(NXDPoint) secondPoint;
  429. - enableDrawing:sender;
  430. - disableDrawing:sender;
  431. - toggleDrawingState:sender;
  432. - colorOn:sender;
  433. - colorOff:sender;
  434. - toggleColor:sender;
  435.  
  436. // Inspector for the palette
  437. - (const char *)inspectorName;
  438.  
  439. // Setting delegate;
  440. - setDelegate:anObject;
  441. - delegate;
  442.  
  443. // Returning Coordinates
  444. - (NXDPoint) getScreenCoordsFor:(double)xVal:(double)yVal;
  445. - (NXDPoint) getWorldCoordsFor:(double)xVal:(double)yVal;
  446.  
  447. // Methods to return data
  448. - dataPoints;
  449. - (int) fillDataArray:(NXDPoint *)dataArray ofLength:(int)aLength;
  450. - (int) numberOfPoints;
  451.  
  452. // Delegate of controlPanel
  453. - windowDidResignKey:sender;
  454. - windowWillClose:sender;
  455.  
  456. - free;
  457.  
  458. // Expanding to new window
  459. - expandToNewWindow:sender;
  460.  
  461. @end
  462.